#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#define cmax 1015
int fac[cmax][cmax];
char x[cmax], y[cmax];
int max(int a, int b) {
    return (a > b) ? a : b;
}
int main() {
    int n;
    while (scanf("%d", &n) != EOF && n != 0) {
        memset(fac, 0, sizeof(fac));
        int i, j;
        char tt;
        for (i = 0; i < n; ++i) {
            scanf(" %c", &tt);
            x[i] = tt;
        }
        for (j = 0; j < n; ++j) {
            scanf(" %c", &tt);
            y[j] = tt;
        }
        for (i = 1; i <= n; ++i) {
            for (j = 1; j <= n; ++j) {
                if (x[i - 1] == y[j - 1]) {
                    fac[i][j] = fac[i - 1][j - 1] + 1;
                }
                else {
                    fac[i][j] = max(fac[i][j - 1], fac[i - 1][j]);
                }
            }
        }
        int z = fac[n][n];
        if ((double)z / n > 0.5) {
            printf("No\n");
        }
        else {
            printf("Yes\n");
        }
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
int tb[200][200];
int sum[200][200];
int a[200];
int main() {
    int n;
    while (scanf("%d", &n) != EOF) {
        for (int i = 0; i < n; i++)
            scanf("%d", &a[i]);
        printf("%d", solve(n));
        printf("\n");
    }
    return 0;
}
int solve(int n) {
    for (int i = 1; i <= n; i++)
        tb[i][i] = 0;
    for (int i = 1; i <= n; i++)
        sum[i][i] = a[i - 1];
    for (int i = 1; i < n; i++)
        for (int j = i + 1; j <= n; j++) {
            sum[i][j] = sum[i][j - 1] + a[j - 1];
        }
    for (int r = 2; r <= n; r++)
        for (int i = 1; i <= n - r + 1; i++)
        {
            int j = i + r - 1;
            tb[i][j] = tb[i][i] + tb[i + 1][j] + sum[i][j];
            for (int k = i + 1; k < j; k++) {
                int t = tb[i][k] + tb[k + 1][j] + sum[i][j];
                if (tb[i][j] > t)
                    tb[i][j] = t;
            }
        }
    return tb[1][n];
}

#include <stdio.h>
#include <stdlib.h>
int tb[200][200];
int s[200][200];
int main() {
    int n;
    int a[200];
    while (~scanf("%d", &n)) {
        for (int i = 0; i < n; i++)
            scanf("%d", &a[i]);
        solve(a, n - 1);
        traceback(1, n - 1);
    }
    return 0;
}
int solve(int a[], int n) {
    for (int i = 1; i <= n; i++)
        tb[i][i] = 0;
    for (int r = 2; r <= n; r++)
        for (int i = 1; i <= n - r + 1; i++) {
            int j = i + r - 1;
            tb[i][j] = tb[i][i] + tb[i + 1][j] + a[i - 1] * a[i] * a[j];
            s[i][j] = i;
            for (int k = i + 1; k < j; k++)
            {
                int t = tb[i][k] + tb[k + 1][j] + a[i - 1] * a[k] * a[j];
                if (tb[i][j] > t) {
                    tb[i][j] = t;
                    s[i][j] = k;
                }
            }
        }
    return tb[1][n];
}
void traceback(int i, int j) {
    if (i == j) return 0;
    traceback(i, s[i][j]);
    traceback(s[i][j] + 1, j);
    printf("A[%d:%d] * A[%d:%d]\n", i, s[i][j], s[i][j] + 1, j);
}

#include <stdio.h>
#include <stdlib.h>
int tb[200][200];
int main() {
    int n;
    int a[200];
    while (scanf("%d", &n) != EOF) {
        for (int i = 0; i < n; i++)
            scanf("%d", &a[i]);
        printf("%d", solve(a, n - 1));
        printf("\n");
    }
    return 0;
}
int solve(int a[], int n) {
    for (int i = 1; i <= n; i++)
        tb[i][i] = 0;
    for (int r = 2; r <= n; r++)
        for (int i = 1; i <= n - r + 1; i++) {
            int j = i + r - 1;
            tb[i][j] = tb[i][i] + tb[i + 1][j] + a[i - 1] * a[i] * a[j];
            for (int k = i + 1; k < j; k++)
            {
                int t = tb[i][k] + tb[k + 1][j] + a[i - 1] * a[k] * a[j];
                if (tb[i][j] > t) {
                    tb[i][j] = t;
                }
            }
        }
    return tb[1][n];
}

#include <stdio.h>
#include <stdlib.h>
int bwl[2000][2000];
int main() {
    int a[2000];
    int n;
    while (scanf("%d", &n) != EOF) {
        for (int i = 0; i < n; i++)
            scanf("%d", &a[i]);
        printf("%d", solve(a, 1, n - 1));
        printf("\n");
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                bwl[i][j] = 0;
    }
    return 0;
}
int solve(int a[], int i, int j) {
    if (bwl[i][j] > 0) return bwl[i][j];
    if (i == j) return 0;
    int u = solve(a, i, i) + solve(a, i + 1, j) + a[i - 1] * a[i] * a[j];
    for (int k = i + 1; k < j; k++)
    {
        int t = solve(a, i, k) + solve(a, k + 1, j) + a[i - 1] * a[k] * a[j];
        if (t < u)
            u = t;
    }
    bwl[i][j] = u;
    return u;
}

#include <stdio.h>
int main() {
    int n;
    while (scanf("%d", &n) != EOF) {
        int a[100][100];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                scanf("%d", &a[i][j]);
            }
        }
        for (int r = 0; r < n; r++) {
            int max = a[0][r];
            int min = a[0][r];
            for (int i = 0; i < n - r; i++) {
                int j = i + r;
                if (max < a[i][j]) {
                    max = a[i][j];
                }
                if (min > a[i][j]) {
                    min = a[i][j];
                }
            }
            printf("L%d=%d, S%d=%d\n", r + 1, max, r + 1, min);
        }
    }
    return 0;
}

#include <stdio.h>
int main() {
    int n;
    while (scanf("%d", &n) != EOF) {
        int a[100][100];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                scanf("%d", &a[i][j]);
            }
        }
        for (int r = 0; r < n; r++) {
            int max = a[0][r];
            int min = a[0][r];
            for (int i = 0; i < n - r; i++) {
                int j = i + r;
                if (max < a[i][j]) {
                    max = a[i][j];
                }
                if (min > a[i][j]) {
                    min = a[i][j];
                }
            }
            printf("L%d=%d, S%d=%d\n", r + 1, max, r + 1, min);
        }
    }
    return 0;
}